import React from 'react';
import { renderNumber } from '@/utils/common';
import { format } from '@/utils/datetime';
import CommonPage from '@/components/page/CommonPage';
const daoName = 'Khdj';
const importName = 'Khdj';
const columns: API.Column[] = [
  {
    title: '客户号',
    width: 110,
    sorter: true,
    dataIndex: 'CUNO',
    key: 'CUNO',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '客户姓名',
    width: 110,
    sorter: true,
    dataIndex: 'CUNM',
    key: 'CUNM',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '性别',
    width: 110,
    sorter: true,
    dataIndex: 'Sex',
    key: 'Sex',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '生日',
    width: 100,
    sorter: true,
    key: 'Birthday',
    dataIndex: 'Birthday',
    render: (data: any) => format(data, 'yyyy-MM-dd'),
    dispaly: true,
    filter: true,
    canEdit: true,
    export: true,
  },
  {
    title: '收入(万元)',
    width: 110,
    className: 'column-money',
    sorter: true,
    dataIndex: 'SRWY',
    render: (data) => renderNumber('.2f', data),
    key: 'SRWY',
    dispaly: true,
    align: 'right',
    filter: true,
    export: true,
  },
  {
    title: '家庭住址',
    width: 110,
    sorter: true,
    dataIndex: 'Address',
    key: 'Address',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '政治面貌',
    width: 110,
    sorter: true,
    dataIndex: 'ZZMM',
    key: 'ZZMM',
    dispaly: true,
    filter: true,
    export: true,
  },
];

const controlsImport: API.Control[] = [
  { name: 'CUNO', type: 'number', label: '客户号', grid: 12 / 24 },
  { name: 'CUNM', type: 'text', label: '客户姓名', grid: 12 / 24 },
  { name: 'Sex', type: 'text', label: '性别', grid: 12 / 24 },
  { name: 'Birthday', dataType: 'date', type: 'date', label: '生日', grid: 12 / 24 },
  {
    name: 'SRWY',
    label: '收入(万元)',
    rules: [{ required: false, message: '不能为空' }],
    type: 'number',
    dataType: 'number',
    grid: 12 / 24,
  },
  { name: 'Address', type: 'text', label: '家庭住址', grid: 12 / 24 },
  { name: 'ZZMM', type: 'text', label: '政治面貌', grid: 12 / 24 },
];

const controls: API.Control[] = [
  { name: 'CUNO', type: 'number', label: '客户号', grid: 12 / 24 },
  { name: 'CUNM', type: 'text', label: '客户姓名', grid: 12 / 24 },
  { name: 'Sex', type: 'text', label: '性别', grid: 12 / 24 },
  { name: 'Birthday', type: 'date', label: '生日', grid: 12 / 24 },
  {
    name: 'SRWY',
    label: '收入(万元)',
    rules: [{ required: false, message: '不能为空' }],
    type: 'number',
    dataType: 'number',
    grid: 12 / 24,
  },
  { name: 'Address', type: 'text', label: '家庭住址', grid: 12 / 24 },
  { name: 'ZZMM', type: 'text', label: '政治面貌', grid: 12 / 24 },
];

const Khdj: React.FC = () => {
  return (
    <CommonPage
      daoName={daoName}
      columns={columns}
      controls={controls}
      title="客户登记"
      importName={importName}
      importControls={controlsImport}
      importMode="InsertAndUpdate"
      importKeys={['CUNO']}
      importTemplateName="客户登记导入模板"
      keyColName="ID"
    />
  );
};
export default Khdj;
